<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 定义局部组件
    //  $(".btn").trigger('click')
    const Child = {
      template:`
        <div>
          这是儿子
        </div>
      `,
      data(){
        return {
          msg:"我是子组件的数据"
        }
      },
      mounted(){
        console.log(this.$parent)
      },
      methods: {
        fn(){
          alert("子组件的方法")
        }
      }
    }
    // 定义全局组件
    const Home = {
      template:`
        <div>
          <h3>这是父组件</h3>
          <child></child>
        </div>
      `,
      data(){
        return {
          msg:"父组件数据"
        }
      },
      mounted(){
       console.log(this.$children)
      },
      components:{
        Child
      }
    }
    Vue.component("Home", Home)
    const vm = new Vue({
      el:"#app"
    })
  </script>
</body>
</html>
